import { EnterpriseEntity } from 'src/modules/enterprise/entities/enterprise.entity';
import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';

@Entity({ name: 'sys_branch' })
export class BranchEntity {
  @PrimaryGeneratedColumn({ name: 'branch_id', type: 'int' })
  branchId: number;

  @Column({ name: 'branch_name', type: 'varchar', length: 255, nullable: true, comment: '网点名称' })
  branchName: string;

  @Column({ name: 'branch_address', type: 'varchar', length: 255, nullable: true, comment: '网点地址 省/市/区/详细地址' })
  branchAddress: string | null;

  @Column({ name: 'branch_lon', type: 'varchar', length: 255, nullable: true })
  branchLon: string | null;

  @Column({ name: 'branch_lat', type: 'varchar', length: 255, nullable: true })
  branchLat: string | null;

  @Column({ name: 'enterprise_id', type: 'char', length: 36, nullable: true, comment: '与企业表关联' })
  enterpriseId: string | null;

  @ManyToOne(() => EnterpriseEntity)
  @JoinColumn({ name: 'enterprise_id' })
  enterprise: EnterpriseEntity;
}
